# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=quarter
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.0
pkgrel=3
pkgdesc="Coin GUI binding for Qt (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://github.com/coin3d/quarter"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-graphviz"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-qt5-tools")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-coin"
         "${MINGW_PACKAGE_PREFIX}-qt5-base")
optdepends=("${MINGW_PACKAGE_PREFIX}-qt5-tools: Designer plugin")
options=('!strip' 'staticlibs' '!buildflags')
source=("quarter-Quarter-${pkgver}.tar.gz::https://github.com/coin3d/quarter/archive/Quarter-${pkgver}.tar.gz"
        'quarter-1.1.0-use-cpack-off.patch'
        'quarter-1.1.0-pc-use-qt5.patch'
        'quarter-1.1.0-fix-plugins-dir.patch')
sha256sums=('392f0c13eea34b4044f4fdcba8757245365dec2c4055e73cf88b287154b81514'
            '52d203a5eabd4d2e21f1cd7b99958633335f7cc547b96e99f2fae42e22315c81'
            '92c3f6074c7c25d5d0cd0cef62443527b74390883a8d61c5610e67c0cf85e36a'
            'a5410e13760fcd24798a8bcd37874a733ae31a2b7a026059d42968c7469e19be')

prepare() {
  cd "${srcdir}/quarter-Quarter-${pkgver}"
  patch -p1 -i "${srcdir}/quarter-1.1.0-use-cpack-off.patch"
  patch -p1 -i "${srcdir}/quarter-1.1.0-pc-use-qt5.patch"
  patch -p1 -i "${srcdir}/quarter-1.1.0-fix-plugins-dir.patch"
}

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DQUARTER_BUILD_PLUGIN=ON \
    -DQUARTER_BUILD_EXAMPLES=OFF \
    -DQUARTER_BUILD_DOCUMENTATION=ON \
    -DQUARTER_USE_CPPFLAGS=-DQUARTER_DLL \
    ../quarter-Quarter-${pkgver}

  cmake --build .
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  DESTDIR=${pkgdir} cmake --install .

  install -Dm644 "${srcdir}/quarter-Quarter-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}

# vim:set ts=2 sw=2 et:
